home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10874 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.6 KB  |  51 lines

  1. Path: krtkg1.rug.ac.be!colle
  2. From: Christophe Colle <colle@krtkg1.rug.ac.be>
  3. Newsgroups: comp.lang.c
  4. Subject: symbol type at runtime
  5. Date: Wed, 20 Mar 1996 17:08:12 +0100
  6. Organization: University of Ghent, Belgium
  7. Message-ID: <Pine.OSF.3.91.960320170224.19850A-100000@krtkg1.rug.ac.be>
  8. NNTP-Posting-Host: krtkg1.rug.ac.be
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11.  
  12. Hi all,
  13.  
  14. I wonder if there is a way to find out the type of a variable at runtime, 
  15. without using tricks like #define etc.
  16.  
  17. eg:
  18.  
  19. char array[10];
  20.  
  21. int function(int blah, char *ptr)
  22. {
  23.   /* in this function i want to find the exact type of the variabl which 
  24.      is passed in ptr. I want to find a char  array[10] and not char * 
  25.      when called with    function(blah, array);
  26.   /*
  27.  
  28. main()
  29. {
  30.   function(0, array);
  31. }
  32.  
  33. I think I should be able to get the exact type of the variables by 
  34. examing the stack frames, but I never did it and I have only man-pages 
  35. which aren't enough. Are there some people around who could tell me on 
  36. how to do what I want, or give me some links to good reference materials 
  37. and examples? I'm running on a DEC-ALPHA.
  38.  
  39. Any help is appreciated. Thanks in advance.
  40.  
  41.  
  42. Christophe Colle
  43.  
  44.      | \       =============================================================  
  45.      |  \      Colle Christophe                      Phone: +32-(0)9-2403955  
  46.      +----     mail: colle@krtkg1.rug.ac.be   http://krtkg1.rug.ac.be/~colle
  47.      |                          
  48.  ----------+   When I'm not in Ghent, Then I'm probably Sailing
  49.   \________|   =======     Radiotherapy Department, Ghent      =============
  50.  
  51.